package com.cooldatasoft.support.git;

import org.eclipse.jgit.lib.Repository;

/**
 * User: brano
 */
public class RepositoryProject {
    private Repository repository;
    private long idProject;
    private String name;

    public void setRepository(Repository repository) {
        this.repository = repository;
    }

    public RepositoryProject(Repository repository, long idProject, String name) {
        this.repository = repository;
        this.idProject = idProject;
        this.name = name;
    }

    public RepositoryProject(long idProject, String name) {
        this(null, idProject, name);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        RepositoryProject that = (RepositoryProject) o;

        if (idProject != that.idProject) return false;
        if (!name.equals(that.name)) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = (int) (idProject ^ (idProject >>> 32));
        result = 31 * result + name.hashCode();
        return result;
    }

    public Repository getRepository() {
        return repository;
    }

    public long getIdProject() {
        return idProject;
    }

    public String getName() {
        return name;
    }

    @Override
    public String toString() {
        return "RepositoryProject{" +
                "name='" + name + '\'' +
                ", idProject=" + idProject +
                '}';
    }
}
